---
id: custom-builds
title: Lodash custom builds
layout: default
---

<section>
  <h1>Custom Builds</h1>
  <p>Custom builds make it easy to create lightweight versions of Lodash containing only the features you need. To top it off, we handle all function dependency &amp; alias mapping for you. Review the <a href="{{ site.links.build_differences }}">build differences</a> &amp; pick the one that’s right for you.</p>
  <p>The Lodash command-line interface is available when <a href="https://npmjs.org/package/lodash-cli"><code>lodash-cli</code></a> is installed as a global package:
  {% raw %}
  <div class="highlight shell"><pre><div>$&#xA0;npm&#xA0;i&#xA0;-g&#xA0;npm</div><div>$&#xA0;npm&#xA0;i&#xA0;-g&#xA0;lodash-cli</div><div>$&#xA0;lodash&#xA0;-h</div></pre></div></p>
  {% endraw %}
</section>

<section>
  <h2>Build Types</h2>
  <ul class="chevron">
    <li>Core builds, that are 4 kB, are created using the <code>core</code> modifier.
      {% raw %}
      <div class="highlight shell"><pre>lodash&#xA0;core</pre></div>
      {% endraw %}
    </li>
    <li>Strict builds, with <a href="http://www.ecma-international.org/ecma-262/7.0/#sec-strict-mode-of-ecmascript">ES strict mode</a> enabled, are created using the <code>strict</code> modifier.
      {% raw %}
      <div class="highlight shell"><pre>lodash&#xA0;strict</pre></div>
      {% endraw %}
    </li>
    <li>Modularized builds, with Lodash split into modules, are created using the <code>modularize</code> modifier.
      {% raw %}
      <div class="highlight shell"><pre>lodash&#xA0;modularize</pre></div>
      {% endraw %}
    </li>
  </ul>
</section>

<section>
  <h2>Build Commands:</h2>
  <ul class="chevron">
    <li>Use the <code>category</code> command to pass comma separated categories of functions to include in the build. <span class="rwd-line">Valid categories are <em>“array”</em>, <em>“collection”</em>, <em>“date”</em>, <em>“function”</em>, <em>“lang”</em>, <em>“object”</em>, <em>“number”</em>, <em>“seq”</em>, <em>“string”</em>, &amp; <em>“util”</em>.</span>
      {% raw %}
      <div class="highlight shell"><pre>lodash&#xA0;category=collection,function</pre></div>
      {% endraw %}
    </li>
    <li>Use the <code>exports</code> command to pass comma separated names of ways to export the <code>lodash</code> function. <span class="rwd-line">Valid exports are <em>“amd”</em>, <em>“commonjs”</em>, <em>“es”</em>, <em>“global”</em>, <em>“node”</em>, <em>“npm”</em>, <em>“none”</em>, &amp; <em>“umd”</em>.</span>
      {% raw %}
      <div class="highlight shell"><pre>lodash&#xA0;exports=amd,node</pre></div>
      {% endraw %}
    </li>
    <li>Use the <code>iife</code> command to specify code to replace the <a href="http://benalman.com/news/2010/11/immediately-invoked-function-expression/">IIFE</a> that wraps Lodash.
      {% raw %}
      <div class="highlight shell"><pre>lodash&#xA0;iife=&quot;\!function(window,undefined){%output%}(this)&quot;</pre></div>
      {% endraw %}
    </li>
    <li>Use the <code>include</code> command to pass comma separated names of functions to include in the build.
      {% raw %}
      <div class="highlight shell"><pre>lodash&#xA0;include=each,filter,map</pre></div>
      {% endraw %}
    </li>
    <li>Use the <code>minus</code> command to pass comma separated function/category names to remove from the build.
      {% raw %}
      <div class="highlight shell"><pre>lodash&#xA0;minus=result,shuffle</pre></div>
      {% endraw %}
    </li>
    <li>Use the <code>plus</code> command to pass comma separated function/category names to add to the build.
      {% raw %}
      <div class="highlight shell"><pre>lodash&#xA0;category=array&#xA0;plus=random,template</pre></div>
      {% endraw %}
    </li>
    <li>Use the <code>template</code> command to pass the file path pattern used to match template files to precompile. <span class="rwd-line"><strong>Note:</strong> Precompiled templates are assigned to the <code>_.<span class="me1">templates</span></code> object.</span>
      {% raw %}
      <div class="highlight shell"><pre>lodash&#xA0;template=&quot;./*.jst&quot;</pre></div>
      {% endraw %}
    </li>
    <li>Use the <code>settings</code> command to pass template settings used when precompiling templates.
      {% raw %}
      <div class="highlight shell"><pre>lodash&#xA0;settings=&quot;{interpolate:/\{\{([sS]+?)\}\}/g}&quot;</pre></div>
      {% endraw %}
    </li>
    <li>Use the <code>moduleId</code> command to specify the AMD module ID for Lodash or the module ID used to include Lodash in compiled templates. <span class="rwd-line">Use “none” as the module ID to create compiled templates without a dependency on Lodash.</span>
      {% raw %}
      <div class="highlight shell"><pre>lodash&#xA0;moduleId=underscore</pre></div>
      {% endraw %}
    </li>
  </ul>
</section>

<section>
  <h2>Notes:</h2>
  <ul class="chevron">
    <li>The <code>exports</code> values <em>“es”</em> &amp; <em>“npm”</em> may only be used in conjunction with the <code>modularize</code> command</li>
    <li>The <code>modularize</code> command uses the first <code>exports</code> values as its module format, ignoring subsequent values</li>
    <li>Unless specified by <code>-o</code> or <code>--output</code> all files created are saved to the current working directory</li>
  </ul>

  <p>The following options are also supported:</p>
  <ul class="nowrap">
    <li><code>-c</code>, <code>--stdout</code> ................ Write output to standard output</li>
    <li><code>-d</code>, <code>--development</code> ..... Write only the non-minified development output</li>
    <li><code>-h</code>, <code>--help</code> .................... Display help information</li>
    <li><code>-m</code>, <code>--source-map</code> ....... Generate a source map using an optional source map URL</li>
    <li><code>-o</code>, <code>--output</code> ................ Write output to a given path/filename</li>
    <li><code>-p</code>, <code>--production</code> ....... Write only the minified production output</li>
    <li><code>-s</code>, <code>--silent</code> ............... Skip status updates normally logged to the console</li>
    <li><code>-V</code>, <code>--version</code> ............. Output current version of Lodash</li>
  </ul>
</section>
